<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layui/layui.js" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
    <link rel="stylesheet" href="/css/build.css?v=1">
    <script src="/js/jquery.js"></script>
    <!--    <script src="../../static/layui/layui.js"></script>-->
    <!--    <link rel="stylesheet" href="..css/layui/layui.css">-->
</head>
<style>
    .Impact{
        background-color: #6a79d6;
    }
</style>
<body>
<!--表单-->
<!--<script src="/layui/layui.all.js"></script>-->
<!--<script src="/layui/layui.js"></script>-->
<script src="/js/core.util.js"></script>
<div class="layui-container" id="app">
    <div class="layui-fluid">
        <div class="panel panel-default operation_dept " hidden>
            <div class="panel-heading title"></div>
            <fieldset class="layui-elem-field layui-field-title  " style="margin-top: 25px;">

                <legend style="font-size: 25px;">
                    胸部放射科体检表
                </legend>
                <div class="layui-row">
                    <div class="layui-col-md6">
                        <legend style="font-size: 17px;font-weight: bolder;font-family: 华文宋体">
                            <div align="center">
                                编号：
                                <nobr id="ii"></nobr>
                            </div>
                        </legend>
                    </div>
                    <div class="layui-col-md6">
                        <legend style="font-size: 17px;font-weight: bolder;font-family: 华文宋体">
                            <div align="center">
                                姓名：
                                <nobr id="bb"></nobr>
                            </div>
                        </legend>
                    </div>
                </div>
            </fieldset>
            <form class="layui-form layui-form-pane layui-col-md3 " action="" lay-filter="deptInfo"
                  style="width: 900px;margin-top: 10px;position: center">
                <div class="layui-form-item ">
                    <label class="layui-form-label ">胸部放射检查</label>
                    <div class="layui-input-block">
<!--                         style="  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">-->
                        <input id="Chest_test" type="text"  name="length" lay-verify="title"
                               autocomplete="off" placeholder="请输入胸部放射检查" class="layui-input WithUnit">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">医师意见</label>
                    <div class="layui-input-block">
                        <input id="Chest_idea" type="text" name="weight" lay-verify="title"
                               autocomplete="off" placeholder="请输入医师意见" class="layui-input WithUnit">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">检查医生id</label>
                    <div class="layui-input-block">
                        <input id="Chest_doctor_id" type="text" name="circle"
                               lay-verify="title" autocomplete="off" placeholder="请输入检查医生id"
                               class="layui-input WithUnit">
                    </div>
                </div>

                <div class="layui-form-item"  align="center">
                    <div class="layui-input-block">
                        <button type="submit" class="layui-btn Impact Impact" lay-submit="" lay-filter="save" @click="save">保存
                        </button>
                        <button class="layui-btn layui-btn-primary Impact" id="btn_cancel" @click="backto">返回</button>
<!--                        <button class="layui-btn layui-btn-primary" id="btn_PDF" @click="getpdf">PDF</button>-->
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!--搜索-->
    <div class="demoTable">
        <div class="layui-form-item">
            <!--        搜索ID：-->

<!--            <div class="layui-input-inline">-->
<!--                <input class="layui-input" type="number" name="id" placeholder="请输入学生id" id="demoReload" autocomplete="off">-->
<!--            </div>-->
<!--            <div class="layui-input-inline ">-->
<!--                <button class="layui-btn" data-type="reload" id="searchID">搜索</button>-->
<!--            </div>-->
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                <legend style="font-size: 20px;">领导检查</legend>
            </fieldset>
        </div>
        <table class="layui-hide" id="useruv" lay-filter="useruv"></table>
    </div>
    <div class="layui-form-item"  align="center">
        <div class="layui-input-block" >
<!--            <button type="submit" class="layui-btn" lay-submit="" lay-filter="save" @click="save">提交</button>-->
            <button class="layui-btn layui-btn-primary"  @click="backto">返回</button>
<!--            <button class="layui-btn layui-btn-primary" id="BTN" @click="getpdf">PDF</button>-->
        </div>
    </div>
</div>

<!--表单规范-->
<script>

    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 1) {
                    return '请填写完所有信息';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
            return false;
        });

        //表单赋值
        layui.$('#LAY-component-form-setval').on('click', function () {
            form.val('example', {
                "username": "贤心" // "name": "value"
                , "password": "123456"
                , "interest": 1
                , "like[write]": true //复选框选中状态
                , "close": true //开关状态
                , "sex": "女"
                , "desc": "我爱 layui"
            });
        });

        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function () {
            var data = form.val('example');
            alert(JSON.stringify(data));
        });


    });
</script>

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<script type="text/html" id="barDemo">
    <!--    class="layui-btn layui-btn-xs"-->
    <!--    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>-->
    <a class="layui-btn layui-btn-xs" lay-event="edit">驳回</a>
<!--    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
</script>
<table id="demo" lay-filter="test"></table>

<!--<script src="../../static/layui/layui.js" ></script>-->
<script src="/layui/layui.all.js"></script>
<script src="/layui/layui.js"></script>
<script src="/js/core.util.js"></script>
<script type="text/html" id="xuhao">
    {{d.LAY_TABLE_INDEX+1}}
</script>
<script>

    var tabledata;//表格中的数据
    var perimeters =  window.location.search;
    perimeters = decodeURI(perimeters.substr(1).split('&')[0]);
    perimeters = Number(perimeters);

    var token = CoreUtil.getData("access_token");//header的token
    layui.use('table', function () {
        var table = layui.table;
        var token = CoreUtil.getData("access_token");
        // var table = layui.table;
        //第一个实例
        table.render({
            elem: '#useruv'
            , height: 350
            , headers: {"authorization": token}
            , url: '/boss/getStuTestInfo?Stu_id='+perimeters //数据接口
            // , page: true //开启分页
            // , data:{"Stu_id":1}
            , cols: [
                [ //表头
                    // {checkbox: true, fixed: true},
                    {field:'Table_index',title: '序号', width: 80, sort: true}
                    // {type:'numbers'}
                     // {field: 'Doctor_id', title: '编号', width: 80, sort: true, fixed: 'true'}
                    , {field: 'Doctor_id', title: '医生id', width: 110, sort: true}
                    , {field: 'Doctor_name', title: '医生姓名', width: 110, sort: true}
                    , {field: 'Doctor_idea', title: '医师意见', width: 200, sort: true}
                    , {field: 'Doctor_operation_time', title: '检查时间', width: 150, sort: true}
                    , {field: 'Doctor_department', title: '科室', width: 80, sort: true}


                    , {
                    field: 'Doctor_error', title: '状态', width: 80, sort: true, templet: function (item) {
                        // if (item.Manage_all === "1") {
                        //     return ' <button type="button" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-normal">已填</button>';
                        // }
                        if (item.Doctor_error === "0") {
                            return '<button type="button" class="layui-btn layui-btn-xs layui-btn-radius  layui-btn-primary">正常</button>';
                        }
                        if (item.Doctor_error === "1") {
                            return '<button type="button" class="layui-btn layui-btn-xs layui-btn-radius layui-btn-danger">已驳回</button>';
                        }
                    }
                 }
                    , {field: 'right', fixed:'right' ,title: '操作', width: 90, toolbar: "#barDemo"}
                ]
            ]
            , id: 'testReload'
            // , page: true
            // , height: 400
        });
        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#demoReload');

                table.reload('testReload', {

                    where: {
                        Doctor_id: demoReload.val()
                    }
                });
            }
        };
        //回车搜索
        // var search = document.getElementById("demoReload");
        // search.addEventListener("keyup", function(event) {
        //     event.preventDefault();
        //     if (event.keyCode === 13) {
        //         console.log("hello");
        //         document.getElementById("searchID").click();
        //     }
        // });

        //监听表格复选框选择
        table.on('checkbox(useruv)', function (obj) {
            console.log(obj)
        });
        //监听工具条
        table.on('tool(useruv)', function (obj) {
            var data = obj.data;
            console.log(data);

            if (obj.event === 'detail') {
                layer.msg('ID：' + data.Stu_id + ' 的查看操作');
            } else if (obj.event === 'del') {
                layer.confirm('真的删除行么', function (index) {
                    console.log(data);
                    $.ajax({
                        url: "UVServlet",
                        type: "POST",
                        data: {"uvid": data.id, "memthodname": "deleteuv", "aid": data.aid},
                        dataType: "json",
                        success: function (data) {

                            if (data.state == 1) {
                                obj.del();
                                layer.close(index);
                                layer.msg("删除成功", {icon: 6});
                            } else {
                                layer.msg("删除失败", {icon: 5});
                            }
                        }

                    });
                });
            } else if (obj.event === 'edit') {
                EidtUv(data, obj);

            }
        });

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            setTimeout(function(){ alert("Hello"); }, 3000);
            active[type] ? active[type].call(this) : '';
        });
    //编辑功能
        function EidtUv(data,  obj) {
            console.log(perimeters);
            console.log(obj);

            $.ajax({
                url: "/boss/rejectTest",
                type: "POST",
                headers: {"authorization": token},
                data: {"Stu_id": perimeters,"Table_index":data.Table_index},
                dataType: "json",
                success: function (res) {
                    table.reload('testReload');
                    // if (res.code = '0') {
                    //     // console.log("getAssayInfo:"+res.toString());
                    //     console.log(res.msg);
                    //     console.log(res.data);
                    //     var Chest_test = res.data[0].Chest_test;
                    //     var Chest_idea = res.data[0].Chest_idea;
                    //     var Chest_doctor_id = res.data[0].Chest_doctor_id;
                    //     $("#Chest_doctor_id").val(Chest_doctor_id);
                    //     $("#Chest_idea").val(Chest_idea);
                    //     $("#Chest_test").val(Chest_test);
                    // } else
                    //     alert(res.msg);
                },
                error: function (data) {

                }

            });
        }


    });

//VUE接受表单中的组件
    var app = new Vue({
        el: "#app",
        data: {
            // Assay_test: "",
            // Assay_idea: "",
            // Assay_doctor_id: ""
        },
        methods: {
            save: function () {
                setTimeout(function(){ alert("Hello"); }, 3000);
                $.ajax({
                    url: '/chest/insertChestInfo',
                    method: 'post',
                    headers: {"authorization": token},
                    data: {
                        "chestDoctorId": $("#Chest_doctor_id").val(),
                        "chestIdea": $("#Chest_idea").val(),
                        "chestTest": $("#Chest_test").val(),
                        "stuId": tabledata.Stu_id
                        // "assayAll":"1",
                        // "assayError":"0"
                    },
                    dataType: 'JSON',
                    success: function (res) {
                        if (res.code = '0') {
                            console.log(res);
                        } else
                            alert(res.msg);
                    },
                    error: function (data) {

                    }
                });

            },
            backto:function(){
                window.location.href="/index/boss";

            },
            getpdf:function(){
                $.ajax({
                    url: '/PDF/getPDF',
                    method: 'post',
                    headers: {"authorization": token},
                    data: {
                        // "chestDoctorId": $("#Chest_doctor_id").val(),
                        // "chestIdea": $("#Chest_idea").val(),
                        // "chestTest": $("#Chest_test").val(),
                        // "stuId": tabledata.Stu_id
                        // "assayAll":"1",
                        // "assayError":"0"
                    },
                    dataType: 'JSON',
                    success: function (res) {
                        if (res.code = '0') {
                            console.log(res);
                        } else
                            alert(res.msg);
                    },
                    error: function (data) {

                    }
                });
            }


        },
    })
</script>
<!--表单提交-->
<script>

</script>
</body>

</html>